<?php slot('index','cur'); ?>
<!--主体-->
<div class="wrap-main left">
	<div class="wrap-center">
    	<div class="wrap-cententleft">
        	<div class="cent-titleimg">
                    <img src="<?php echo $skill->getCover(); ?>" style="width:780px;height:488px;" />
                    <div class="title"><div class="t"><?php echo $skill->getRaw('title'); ?></div></div>
            </div>
            <div class="cent-wrap">
            	<div class="cent-user">
                    <i class="phto"><a href="<?php echo url_for('skill/personal?user_id='.$skill->getUser()->getId()); ?>"><img src="<?php echo $skill->getUser()->getCover(); ?>"></a></i>
                    <a href="<?php echo url_for('skill/personal?user_id='.$skill->getUser()->getId()); ?>"><i class="userna"><?php echo $skill->getUser()->getNickname(); ?></i></a>
                    <i class="addtime">&middot;<?php echo $skill->getTimeAgoToString(); ?></i>
                    <span><a href="javascript:void(0);" id="fav_skill" skill_id="<?php echo $skill->getId(); ?>">收藏</a><a href="javascript:void(0);" id="like_skill" skill_id="<?php echo $skill->getId(); ?>">点赞</a></span>
                </div>
                <div class="cent-main" style="white-space:normal;word-break: break-all;">
                    <!--这里的ul编辑页面的内容-->
                    <ul id="sortable">
                        <?php foreach($skill->getBlocks() as $block): ?>
                            
                                <?php if($block->getBType() == 3): ?>
                                   <li value="2">
                                        <?php echo $block->getRaw('content'); ?>
                                    </li>
                                <?php elseif($block->getBType() == 2): ?>
                                   <li value="1">
                                       <p><?php echo $block->getRaw('content'); ?></p>
                                    </li>
                                 <?php elseif($block->getBType() == 1): ?>
                                    <li value="3" style="padding:0px;"><?php echo $block->getRaw('content'); ?></li>
                                <?php endif; ?>
                            <?php endforeach; ?>
                        
                    </ul>
                    <!--这里的ul编辑页面的内容-->
                </div>
                <ul class="cent-tab">
                	<li><i>适用：</i><?php echo $skill->getAgeRangeToString(); ?>岁</li>
                    <li><i>标签：</i>
                        <?php foreach($skill->getTags() as $tag): ?>
                        <span><?php echo $tag; ?></span>
                        <?php endforeach; ?>
                    </li>
                </ul>
            </div>
        </div>
        
        <div class="wrap-cententright">
        	<div class="wrap-right-vouser" style="width:419px;margin-top:0px;padding-bottom:0px;">
                <div class="vo-userlist big">
                    <div class="vo-userpto"><a href="<?php echo url_for('skill/personal?user_id='.$skill->getUser()->getId()); ?>"><img src="<?php echo $skill->getUser()->getCover(); ?>" /></a></div>
                    <div class="vo-userna"><a href="<?php echo url_for('skill/personal?user_id='.$skill->getUser()->getId()); ?>" style="text-decoration: none;"><i><?php echo $skill->getUser()->getNickname(); ?></i></a><br/>
                        <span>
                            <?php 
                            $data = array();
                            foreach($skill->getUser()->getChilds() as $child){
                                $data[] =  $child->getChildOld().'岁'.$child->getErziNverToString();
//                            岁儿子、2岁儿子
                            }
                            echo implode('、',$data);
                            ?>
                            的<?php echo User::$roles[$skill->getUser()->getRole()]; ?>
                        </span>
                    </div>
                    <div class="vo-usergz" >
                        <?php if($sf_user->isAuthenticated()): ?> 
                            <?php if(UserAttentionTable::getInstance()->hasAttentionUser($sf_user->getAttribute('user_id',0), $skill->getUser()->getId())): ?>
                                <a href="javascript:void(0);" id="attention" user_id="<?php echo $skill->getUser()->getId(); ?>" >已关注</a>
                            <?php else: ?>
                                <a href="javascript:void(0);" id="attention" user_id="<?php echo $skill->getUser()->getId(); ?>" >关注</a>
                            <?php endif; ?>
                        <?php else: ?>
                             <a href="javascript:void(0);" id="attention" user_id="<?php echo $skill->getUser()->getId(); ?>" >关注</a>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="vo-usertalnum">
                    <div>
                        <i><?php echo NewSkillTable::getInstance()->getUserSkillNumber($skill->getUser()->getId()); ?>篇</i>
                        <br/>
                        <span style="color: #808080;">发现</span>
                    </div>
                    <div>
                        <i><?php echo NewSkillTable::getInstance()->getUserSkillReadNumber($skill->getUser()->getId()); ?></i>
                        <br />
                        <span style="color: #808080;">总阅读量</span>
                    </div>
                    <div>
                        <i id="fans_num"><?php echo UserStatisticalTable::getInstance()->getStatistical($skill->getUser()->getId())->getFansNum(); ?></i>
                        <br />
                        <span style="color: #808080;">粉丝</span>
                    </div>
                </div>
            </div>
            
            <div class="wrap-pl">
            	<div class="wrap-plc">
                	<div class="wrap-plt"><i>评论（<?php echo $skill->getStatistical()->getCommentNum(); ?>）</i>
                            <?php if($sf_user->isAuthenticated()): ?>    
                            <span id="post_comment">发送</span>
                            <?php endif; ?>
                        </div>
                        
                    <?php if(!$sf_user->isAuthenticated()): ?>    
                    <!--未登录-->
                    <div class="wrap-plno"><a href="<?php echo url_for('user/login'); ?>">登录</a>后参与讨论</div>
                    <!--未登录-->
                    <?php else: ?>
                    <form action="<?php echo url_for('skill/add_comment'); ?>" method="POST" id="add_comment">
                    <!--登录后-->
                    <div class="wrap-plyes" style="">
                        <textarea name="content" id="comment_content" placeholder="请输入评论内容"></textarea>
                        <input type="hidden" name="skill_id" value="<?php echo $skill->getId(); ?>" />
                    </div>
                    <!--登录后-->
                    </form>
                    <?php endif; ?>
                    
                    <div class="wrap-plist">
                        <?php  foreach(SkillCommentTable::getInstance()->getSkillComment($skill->getId()) as $comment): ?>
                    	<div class="wrap-plong">
                        	<div class="pl-phto"><img src="<?php echo $comment->getUser()->getCover(); ?>" /></div>
                            <div class="pl-user">
                            	<div class="pl-userc">
                                	<div class="pl-usercna"><i><?php echo $comment->getUser()->getNickname(); ?></i>
                                            <!--<span>3</span>-->
                                        </div>
                                    <div class="pl-usertime"><?php echo $comment->getTimeAgoToString(); ?></div>
                                </div>
                                <div class="pl-usercont">
                                	<?php echo $comment->getContent(); ?>
                                </div>
                            </div>
                        </div>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$(document).ready(function(){
    
    
    
    $("#post_comment").click(function(){
        var length = $.trim($("#comment_content").val()).length;
        
        if(length == 0){
            alert('请先填写评论内容！');
            return ;
        }else{
            $("#add_comment").submit();
        }
    });
    
    $("#fav_skill").click(function(){
        
        var skill_id = $(this).attr('skill_id');
        
        $.post('<?php echo url_for('skill/fav'); ?>',{'skill_id': skill_id},function(data){
            var data = eval('('+data+')');
            var error = data.error;
            var msg = data.msg;
            
            alert(msg);
            
        });
    });
    
    $("#attention").click(function(){
        
        var skill_id = $(this).attr('user_id');
        
        $.post('<?php echo url_for('skill/user_attention'); ?>',{'user_id': skill_id},function(data){
            var data = eval('('+data+')');
            var error = data.error;
            var msg = data.msg;
            var fans = data.fans;
            
            alert(msg);
            
            if(error == 0){
                 $("#attention").text('已关注');
                 $("#fans_num").text(fans);
                 
            }else if(error == 1){
                $("#attention").text('关注');
                 $("#fans_num").text(fans);
            }
            
        });
    });
    
    
    //没有对技能点赞的数据表
    $("#like_skill").click(function(){
        var skill_id = $(this).attr('skill_id');
//        alert("#debug");
        $.post('<?php echo url_for('skill/like'); ?>',{'skill_id': skill_id},function(data){
            var data = eval('('+data+')');
            var error = data.error;
            var msg = data.msg;
            
            alert(msg);
            
        });
    });
    
});

</script>